<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>    
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>
<body>
    <div id="app">
        <p>{{msg}}</p>
        <!-- msg->:value='msg'->props value->:value='value' -->
        <!-- @input ($event.target.value)-> input msg=$event  -->
        <my-component v-bind:value="msg" v-on:input="msg=$event"></my-component>
        <!-- v-model双向绑定  默认是input事件 默认绑定的属性叫value   子组件中props写value 触发的事件名称是input -->
        <my-component v-model="msg"></my-component>
    </div>
    <script>
        Vue.component("my-component",{
            props:['value'],
            template:`
            <div>
                <input type="text" v-bind:value=value @input="$emit('input',$event.target.value)">               
            </div>
            `
        });




      new Vue({
          el:"#app",
          data:{
              msg:"你好"
          },
      });
    
    </script>
</body>
</html>